import Base from 'models/base';

import moment from 'moment';

const typeData = ['未开始', '进行中', '已结束'];

export default class GoodsAuction extends Base {
  constructor(auction) {
    super();

    this.defId = auction.goodsDefId;
    this.goodId = auction.activityGoodsId;
    this.name = auction.goodsName;
    this.pic = this.getOnePic(auction.goodsPic);
    this.price = auction.activityPrice;

    let startTime = auction.activityStartTime;
    this.startTime = moment(startTime, 'MM-DD HH:mm:ss').valueOf();

    let endTime = auction.activityEndTime;
    this.endTime = moment(endTime, 'MM-DD HH:mm:ss').valueOf();

    let typeText = auction.timeType;
    let type = typeData.indexOf(typeText);
    this.typeText = typeText;
    this.type = type;

    if (type === 2) {
      this.priceText = '成交价';
    } else {
      this.priceText = '当前价';
    }
  }
}
